import * as Cesium from 'cesium/Cesium'
import VisibilityState from "./VisibilityState";

var cartesianScratch$1 = new Cesium.Cartesian3
    , rayScratch$1 = new Cesium.Ray
    , visibilityState = new VisibilityState;

function getWorldPosition(e, t, i) {
    var r;
    if (e.pickPositionSupported) {
        visibilityState.hide(e);
        var n = e.pick(t, 1, 1);
        if (visibilityState.restore(e),
        Cesium.defined(n) && (n instanceof Cesium.Cesium3DTileFeature
            || n.primitive instanceof Cesium.Cesium3DTileset || n.primitive instanceof Cesium.Model)
        && Cesium.defined(r = e.pickPosition(t, cartesianScratch$1)))
            return Cesium.Cartesian3.clone(r, i)
    }
    if (Cesium.defined(e.globe)) {
        var a = e.camera.getPickRay(t, rayScratch$1);
        return Cesium.defined(r = e.globe.pick(a, e, cartesianScratch$1)) ? Cesium.Cartesian3.clone(r, i) : void 0
    }
}

export default getWorldPosition;